
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jifRegistrarSuministros.java
 *
 * Created on 14-oct-2010, 8:18:06
 */

package Suministros;

import administracion.delegate.GestionPedidosDelegate;
import administracion.helper.Listas;
import administracion.helper.Utiles_MensajesDialogo;
import com.jidesoft.hints.ListDataIntelliHints;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import suministros.ejb30.TO.SuministroTO;
import suministros.ejb30.entity.GrupoSuministros;
import suministros.ejb30.TO.GrupoSuministrosTO;
import suministros.ejb30.TO.TipoTO;
import suministros.ejb30.entity.Suministros;
import suministros.ejb30.entity.Tipo;

/**
 *
 * @author Diana
 */
public class jifRegistrarSuministros extends javax.swing.JInternalFrame {
    private ListDataIntelliHints intelliHintsSuministros;
    SuministroTO suministro;
    /** Creates new form jifRegistrarSuministros */
    public jifRegistrarSuministros() {

        initComponents();
        cargaHintsIndependientes();
        this.llenarComboTipoABC();
        this.llenarComboTipoStock();
        this.llenarComboTipoUnidadMedida();
        this.llenarComboGrupoSuministros();
    }
     private void cargaHintsIndependientes() {
    this.intelliHintsSuministros = new ListDataIntelliHints(this.jtfDescSuministro, Listas.getSuministros());
  }
     private void llenarComboTipoABC() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo1.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("Tipo_ABC");

          this.cboBeanBindingTipo1.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcbTipo.updateUI();
          this.jcbTipo.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarSuministros.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      private void buscarSuministros()
  {
    this.suministro = null;
    SuministroTO sumi;
    if (this.jtfCodSuministro.getText().trim().length() < 1) {

      try { sumi = (SuministroTO)this.intelliHintsSuministros.getSelectedHint();
      } catch (NullPointerException ex) {
        sumi = null;
      }
    } else {
      sumi = Listas.getSuministroCodigo(this.jtfCodSuministro.getText().trim());
    }

    if (sumi == null) {
      Utiles_MensajesDialogo.mensajeError("El suministro no existe!");
      this.jtfDescSuministro.setText("");
      this.jbtAceptar.setEnabled(false);
     } else {
      this.jtfDescSuministro.setText(sumi.toString());
      this.jtfCodSuministro.setText(sumi.getId_suministro());
      this.jtfCodSuministro.setEditable(false);
      this.jbtAceptar.setEnabled(true);
      this.suministro = sumi;
    }
  }
      private void llenarComboTipoUnidadMedida() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo2.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("tipo_unidad_medida");

          this.cboBeanBindingTipo2.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcbTipoUnidad.updateUI();
          this.jcbTipoUnidad.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarSuministros.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
       private void llenarComboTipoStock() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingTipo3.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getTipo_porTabla("tipo_stock");

          this.cboBeanBindingTipo3.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcbTipoStock.updateUI();
          this.jcbTipoStock.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarSuministros.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
        private void llenarComboGrupoSuministros() {
        List listaTipos1 = null;
        List listaTipos_cbo1 = this.cboBeanBindingGrupoSuministro1.getLista();
        listaTipos_cbo1.clear();
        try
        {
          listaTipos1 = Listas.getGruposuministros();

          this.cboBeanBindingGrupoSuministro1.setLista(listaTipos1);
          this.bindingGroup.bind();
          this.jcbGrupo.updateUI();
          this.jcbGrupo.setSelectedIndex(-1);
        } catch (Exception ex) {
          Utiles_MensajesDialogo.mensajeAlerta("Error al obtener Tipos\n" + ex.getMessage());
          ex.printStackTrace();
          Logger.getLogger(jifRegistrarSuministros.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
        public void registrar(){

            String grupo=((GrupoSuministrosTO)this.jcbGrupo.getSelectedItem()).getCodigo();
            int tipo=((TipoTO)this.jcbTipo.getSelectedItem()).getId_tabla_tipo();
            int tipos=((TipoTO)this.jcbTipoStock.getSelectedItem()).getId_tabla_tipo();
            int tipou=((TipoTO)this.jcbTipoUnidad.getSelectedItem()).getId_tabla_tipo();
            Suministros sumi= new Suministros();
            sumi.setAlta(true);
            sumi.setCodGrupoSumi(new GrupoSuministros(grupo));
            sumi.setCodigoAnterior(this.jtfCodigo.getText());
            sumi.setDescripcion(this.jtfDescripcion.getText());
            if(this.jtfPrecio.getText().length()==0){
            sumi.setPrecioMercado(BigDecimal.ZERO);
            }
            else
            sumi.setPrecioMercado(new BigDecimal(this.jtfPrecio.getText()));
            sumi.setTipoABC(new Tipo(tipo));
            sumi.setTipoStock(new Tipo(tipos));
            sumi.setTipoUnidadMedida(new Tipo(tipou));
            sumi.setEspecificaciones(this.jtfEspecificaciones.getText());
            sumi.setIdDescarte(this.jtfCodSuministro.getText());
            boolean prod=false;
            if(this.jcbMateriaPrima.isSelected()){
                prod=true;
            }
            sumi.setFlagMateriaPrima(prod);
        try {
            GestionPedidosDelegate.getInstance().insertarSuministro(sumi);
             Utiles_MensajesDialogo.mensajeExito();
        } catch (Exception ex) {
             Utiles_MensajesDialogo.mensajeError("No se pudo completar la transaccion");
        }

        }

        public boolean validar(){
            boolean estado=true;
            if(this.jcbTipo.getSelectedIndex()==-1){
                Utiles_MensajesDialogo.mensajeAlerta("Debe seleccionar un tipo");
                estado=false;
            }
             if(this.jcbTipoUnidad.getSelectedIndex()==-1){
                Utiles_MensajesDialogo.mensajeAlerta("Debe seleccionar un tipo de unidad de medida");
                estado=false;
            }
             if(this.jcbTipoStock.getSelectedIndex()==-1){
                Utiles_MensajesDialogo.mensajeAlerta("Debe seleccionar un tipo de stock");
                estado=false;
            }
             if(this.jcbGrupo.getSelectedIndex()==-1){
                Utiles_MensajesDialogo.mensajeAlerta("Debe seleccionar un grupo de suministros");
                estado=false;
            }
             if(this.jtfDescripcion.getText().compareTo("")==0){
                Utiles_MensajesDialogo.mensajeAlerta("Debe ingresar un nombre de suministro");
                estado=false;
            }
            return estado;
        }
    public void limpiar(){
           this.jtfCodSuministro.setText("");
           this.jtfDescSuministro.setText("");
           this.jtfEspecificaciones.setText("");
           this.jtfPrecio.setText("");
           this.jtfCodigo.setText("");
           this.jcbGrupo.setSelectedIndex(-1);
           this.jcbTipo.setSelectedIndex(-1);
           this.jcbTipoStock.setSelectedIndex(-1);
           this.jcbTipoUnidad.setSelectedIndex(-1);
       }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        cboBeanBindingTipo1 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo2 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo3 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingTipo4 = new administracion.BeanBinding.CboBeanBindingTipo();
        cboBeanBindingGrupoSuministro1 = new administracion.BeanBinding.CboBeanBindingGrupoSuministro();
        jLabel1 = new javax.swing.JLabel();
        jtfDescripcion = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jcbTipo = new javax.swing.JComboBox();
        jcbTipoUnidad = new javax.swing.JComboBox();
        jcbTipoStock = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jtfCodigo = new javax.swing.JTextField();
        jtfPrecio = new javax.swing.JTextField();
        jcbGrupo = new javax.swing.JComboBox();
        jbtAceptar = new javax.swing.JButton();
        jbtCancelar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jtfEspecificaciones = new javax.swing.JTextField();
        jcbMateriaPrima = new javax.swing.JCheckBox();
        jLabel11 = new javax.swing.JLabel();
        jtfDescSuministro = new javax.swing.JTextField();
        jtfCodSuministro = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();

        setTitle("REGISTRAR SUMINISTROS");

        jLabel1.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel1.setText("DESCRIPCION:");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel2.setText("TIPO UNIDAD DE MEDIDA:");

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel3.setText("TIPO STOCK:");

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel4.setText("TIPO ABC:");

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo1, eLProperty, jcbTipo);
        bindingGroup.addBinding(jComboBoxBinding);

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo2, eLProperty, jcbTipoUnidad);
        bindingGroup.addBinding(jComboBoxBinding);

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingTipo3, eLProperty, jcbTipoStock);
        bindingGroup.addBinding(jComboBoxBinding);

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel5.setText("CODIGO ANTERIOR:");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel6.setText("PRECIO DEL MERCADO:");

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel7.setText("GRUPO SUMINISTRO:");

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${lista}");
        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cboBeanBindingGrupoSuministro1, eLProperty, jcbGrupo);
        bindingGroup.addBinding(jComboBoxBinding);

        jcbGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbGrupoActionPerformed(evt);
            }
        });
        jcbGrupo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jcbGrupoKeyPressed(evt);
            }
        });

        jbtAceptar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_ok.png"))); // NOI18N
        jbtAceptar.setMnemonic('A');
        jbtAceptar.setText("ACEPTAR");
        jbtAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtAceptarActionPerformed(evt);
            }
        });
        jbtAceptar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jbtAceptarKeyPressed(evt);
            }
        });

        jbtCancelar.setFont(new java.awt.Font("Arial", 1, 12));
        jbtCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconoscomb/16x16ozygen/actions/button_cancel.png"))); // NOI18N
        jbtCancelar.setMnemonic('C');
        jbtCancelar.setText("CERRAR");
        jbtCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtCancelarActionPerformed(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel8.setText("ESPECIFICACIONES:");

        jcbMateriaPrima.setFont(new java.awt.Font("Arial", 1, 12));
        jcbMateriaPrima.setText("MATERIA PRIMA");

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel11.setText("DESC.DESCARTE");

        jtfDescSuministro.setFont(new java.awt.Font("Arial 12 Simple 12 Simple", 0, 12)); // NOI18N
        jtfDescSuministro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDescSuministroActionPerformed(evt);
            }
        });
        jtfDescSuministro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jtfDescSuministroKeyPressed(evt);
            }
        });

        jtfCodSuministro.setFont(new java.awt.Font("Arial 12 Simple 12 Simple", 0, 12));
        jtfCodSuministro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCodSuministroActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Arial", 1, 12));
        jLabel10.setText("DESCARTE");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jtfPrecio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                                            .addComponent(jtfCodigo, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
                                        .addGap(152, 152, 152))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jcbTipoUnidad, javax.swing.GroupLayout.Alignment.LEADING, 0, 280, Short.MAX_VALUE)
                                            .addComponent(jcbTipo, javax.swing.GroupLayout.Alignment.LEADING, 0, 280, Short.MAX_VALUE)
                                            .addComponent(jcbTipoStock, 0, 280, Short.MAX_VALUE))
                                        .addGap(85, 85, 85))
                                    .addComponent(jtfEspecificaciones, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                                    .addComponent(jtfDescripcion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                                    .addComponent(jcbGrupo, 0, 365, Short.MAX_VALUE)))
                            .addComponent(jcbMateriaPrima, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(10, 10, 10)
                                .addComponent(jtfCodSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(10, 10, 10)
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfDescSuministro, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(152, 152, 152)
                        .addComponent(jbtAceptar)
                        .addGap(3, 3, 3)
                        .addComponent(jbtCancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jcbMateriaPrima)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtfDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jcbTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jcbTipoUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jcbTipoStock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(jtfPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jtfCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbGrupo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfEspecificaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel10))
                    .addComponent(jtfCodSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel11))
                    .addComponent(jtfDescSuministro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtAceptar)
                    .addComponent(jbtCancelar))
                .addGap(13, 13, 13))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtAceptarActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro que desea registrar el suministro?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
         if(validar()){
                this.registrar();
                try {
                    Listas.cargarSuministros();
                    this.limpiar();
                } catch (Exception ex) {
                    Logger.getLogger(jifRegistrarSuministros.class.getName()).log(Level.SEVERE, null, ex);
                }
         }
        }

    }//GEN-LAST:event_jbtAceptarActionPerformed

    private void jbtAceptarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jbtAceptarKeyPressed
        if(KeyEvent.VK_ENTER == evt.getKeyCode() ||KeyEvent.VK_TAB == evt.getKeyCode()  ){
            this.jbtAceptar.doClick();
        }
}//GEN-LAST:event_jbtAceptarKeyPressed

    private void jbtCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtCancelarActionPerformed
        int res = javax.swing.JOptionPane.showConfirmDialog( this,"Esta seguro de salir?",
                "Confirmar",javax.swing.JOptionPane.YES_NO_OPTION );
        if(res==javax.swing.JOptionPane.YES_OPTION){
            this.dispose();
        }
}//GEN-LAST:event_jbtCancelarActionPerformed

    private void jcbGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbGrupoActionPerformed

    }//GEN-LAST:event_jcbGrupoActionPerformed

    private void jcbGrupoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jcbGrupoKeyPressed
      
    }//GEN-LAST:event_jcbGrupoKeyPressed

    private void jtfDescSuministroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDescSuministroActionPerformed

        buscarSuministros();
}//GEN-LAST:event_jtfDescSuministroActionPerformed

    private void jtfDescSuministroKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfDescSuministroKeyPressed

        if (this.jtfCodSuministro.getText().trim().length() > 0){
            this.jtfCodSuministro.setText("");
        }
    }//GEN-LAST:event_jtfDescSuministroKeyPressed

    private void jtfCodSuministroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCodSuministroActionPerformed

        if (this.jtfCodSuministro.getText().trim().length() < 1)
            this.jtfDescSuministro.requestFocus();
        else
            buscarSuministros();
}//GEN-LAST:event_jtfCodSuministroActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private administracion.BeanBinding.CboBeanBindingGrupoSuministro cboBeanBindingGrupoSuministro1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo1;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo2;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo3;
    private administracion.BeanBinding.CboBeanBindingTipo cboBeanBindingTipo4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    public javax.swing.JButton jbtAceptar;
    private javax.swing.JButton jbtCancelar;
    private javax.swing.JComboBox jcbGrupo;
    private javax.swing.JCheckBox jcbMateriaPrima;
    private javax.swing.JComboBox jcbTipo;
    private javax.swing.JComboBox jcbTipoStock;
    private javax.swing.JComboBox jcbTipoUnidad;
    private javax.swing.JTextField jtfCodSuministro;
    private javax.swing.JTextField jtfCodigo;
    private javax.swing.JTextField jtfDescSuministro;
    private javax.swing.JTextField jtfDescripcion;
    private javax.swing.JTextField jtfEspecificaciones;
    private javax.swing.JTextField jtfPrecio;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
